package design.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * \* User: Administrator
 * <p>
 * \* Date: 2020/9/21
 * <p>
 * \* Time: 15:45
 * <p>
 * \* Description:
 * \
 */
public abstract class CarModel {
    private List<String> sequence = new ArrayList<>();

    protected abstract void start();

    protected abstract void stop();

    protected abstract void alarm();

    protected abstract void engineBoom();

    final public void run() {
        for (int i = 0; i < sequence.size(); i++) {
            String name = sequence.get(i);
            if (name.equalsIgnoreCase("start")) {
                this.start();
            }
            if (name.equalsIgnoreCase("stop")) {
                this.stop();
            }
            if (name.equalsIgnoreCase("alarm")) {
                this.alarm();
            }
            if (name.equalsIgnoreCase("engineBoom")) {
                this.engineBoom();
            }
        }
    }

    final public void setSequence(List<String> sequence) {
        this.sequence = sequence;
    }
}
